package com.bw.controller;

import com.bw.domain.Sugar;
import com.bw.domain.SugarDTO;
import com.bw.servioce.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;

    @RequestMapping("getAmount")
    public Map t1(){
        double amount = sugarService.getSugarAmount();
        Map map = new HashMap<>();
        map.put("status",0);
        map.put("data",amount);
        return map;
    }

    @RequestMapping("list1")
    public Map t2(){
        List<Sugar> list = sugarService.getSugarlist1();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("list2")
    public String t3(){
        List<SugarDTO> list = sugarService.getSugarlist2();
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("机构");
        list1.add("完运里程");
        list1.add("完运次数");
        list1.add("完运时长");
        list1.add("每次平均时长");
        list1.add("每次平均里程");
        return SugarUtil.getTablePlayData(list1,list);
    }

    @RequestMapping("list3")
    public Map t4(){
        List<Sugar> list = sugarService.getSugarlist3();
        return SugarUtil.getMapData(list);
    }
}
